<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('profit列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>日期：</label>
                                <input type="text" name="dateInfo" id="dateInfo"/>
                            </li>
<!--                            <li>-->
<!--                                <label>产品名称：</label>-->
<!--                                <input type="text" name="productId"/>-->
<!--                            </li>-->

                            <li>
                                <label>产品ID：</label>
                                <input type="number" name="productId"/>
                            </li>
                            <li>
                                <label>产品名称：</label>
                                <select name="productName"  class="form-control">
                                    <option value="">所有</option>
                                    <option  th:each="item:${productList}" th:text="${item.name}" th:value="${item.name}"></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>是否为联登：</label>-->
<!--                                <input type="text" name="prodcutUnionFlag"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>收益金额：</label>-->
<!--                                <input type="text" name="profitAmount"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

<!--            <div class="btn-group-sm" id="toolbar" role="group">-->
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="product:profit:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:profit:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:profit:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="product:profit:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
<!--            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('product:profit:edit')}]];
        var removeFlag = [[${@permission.hasPermi('product:profit:remove')}]];
        var itemListFlag = [[${@permission.hasPermi('product:profitAddup:view')}]];
        var totalListFlag = [[${@permission.hasPermi('product:profitAddup:total')}]];
        var prefix = ctx + "product/profit";
        var prefixDataList = ctx + "product/profitAddup/";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "profit",
                columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     field: 'id',
                //     title: '',
                //     visible: false
                // },
                {
                    field: 'dateInfo',
                    title: '日期'
                },
                // {
                //     field: 'productId',
                //     title: '产品ID'
                // },
                    {
                        field: 'productName',
                        title: '产品名称',
                        formatter: function (value, row){
                            return row.productName + '[' + row.productId + ']'
                        }
                    },
                // {
                //     field: 'prodcutUnionFlag',
                //     title: '是否为联登',
                //     formatter: function (value,row,index){
                //         return row.prodcutUnionFlag?'<span class="badge badge-primary">是</span>':'<span class="badge badge-danger">否</span>';
                //     }
                // },
                {
                    field: 'dayUvNumber',
                    title: 'uv控量'
                },
                {
                    field: 'uvNumber',
                    title: '今日uv量'
                },
                {
                    field: 'profitAmount',
                    title: '收益金额'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + itemListFlag + '" href="javascript:void(0)" onclick="dataList(\'' + row.id + '\')"><i class="fa fa-list"></i>详细</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + totalListFlag + '" href="javascript:void(0)" onclick="dataTotalList(\'' + row.id + '\')"><i class="fa fa-list"></i>统计</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: '#dateInfo',
                type: 'date'
            });
        });

        /*字典列表-详细*/
        function dataList(id) {
            var url = prefixDataList + id;
            $.modal.openTab("收益历史", url);
        }

        /*字典列表-详细*/
        function dataTotalList(id) {
            var url = prefixDataList + "total/" + id;
            $.modal.openTab("收益统计", url);
        }

    </script>
</body>
</html>